﻿$(function () {
    $(".ph-tabs").kendoTabStrip({});
    kendo.culture("zh-CHS");
});

function GetSexString(sex) {
    var html = "男女";
    if (sex == 1) html = "男";
    else if (sex == 2) html = "女";
    return html;
}

function GetGradeString(code) {
    if (code == null) return "";
    var grades = [
        { code: 11, description: "一年级" },
        { code: 12, description: "二年级" },
        { code: 13, description: "三年级" },
        { code: 14, description: "四年级" },
        { code: 15, description: "五年级" },
        { code: 16, description: "六年级" },
        { code: 21, description: "七年级" },
        { code: 22, description: "八年级" },
        { code: 23, description: "九年级" },
        { code: 31, description: "高一" },
        { code: 32, description: "高二" },
        { code: 33, description: "高三" },
        { code: 41, description: "大一" },
        { code: 42, description: "大二" },
        { code: 43, description: "大三" },
        { code: 44, description: "大四" }
    ];
    var ret = "";
    code = code.toString();
    var codes = code.split(',');
    if (codes.length == 16) return "所有年级";
    $.each(codes,function (i, o) {
        $.each(grades, function (k, p) {
            if (p.code == o) {
                ret += "&nbsp;" + p.description;
            }
        });
    });
    return ret;
}

function ShowLevelScore(l) {
    switch (l) {
        case 1:
            return "不及格";
        case 2:
            return "及格";
        case 3:
            return "良好";
        case 4:
            return "优秀";
        default:
            return "";
    }
}

function ShowGradeLevel(lg) {
    switch (lg) {
        case 1:
            return "小学";
        case 2:
            return "初中";
        case 3:
            return "高中";
        case 4:
            return "大学";
        default:
            return "";
    }
}

function ShowTime(second) {
    var minute = parseInt(second / 60);
    if (minute > 0)
        return minute + "'" + (second - minute * 60);
    else
        return second;
}

function GetFileProgress(guid, pb) {
    var file = Whale.Remote.GetEntity({
        url: "/Files/GetFileProgressing",
        parameters: { guid: guid },
    });
    if (file != null) {
        if (file.NowRow < file.Rows) {
            setTimeout(function () {
                GetFileProgress(guid, pb);
            }, 5000);
        }
        var percent = file.NowRow * 100 / file.Rows;
        pb.value(percent);
    }
}

$(function () {
    $("#fileAux").kendoUpload({
        localization: {
            select: "选择文件",
            dropFilesHere: "",
            headerStatusUploaded: "",
            headerStatusUploading: "",
            statusUploading:"",
            uploadSelectedFiles:""
        },
        multiple: false,
        showFileList: false,
        async: {
            saveUrl: "/Files/ExcelUpLoad",
            autoUpload: true
        },
        select: function (e) {
            var files = e.files;
            $.each(files, function () {
                if (this.extension.toLowerCase() != ".xls") {
                    wndGeneralInformation.content("请选择Excel2003文件。").open();
                    e.preventDefault();
                }
            });
        },
        upload: function (e) {
            $("#fileAux").attr("data-fid", "");
            $("#fuAuxMsg").html("<img src='/Content/images/loading_80×10.gif' />");
        },
        success: function (e) {
            if (e.response != null) {
                if (e.response.Success) {
                    $("#fuAuxMsg").html(e.files[0].name);
                    $("#fileAux").attr("data-fid", e.response.Data.Guid);
                    
                }
                else {
                    $("#fileAux").attr("data-fid", "");
                    wndGeneralInformation.content(e.response.Message).open();
                }
            }
            $(".k-upload-status-total").remove();
        },
        error: function (e) {
            console.log("Er", e);
        }
    });
});


